package com.curvebreakers.wheresmystuff.model;

import java.util.Arrays;
import java.util.List;

/**
 * Represents the category of a entry.
 * @author evan.cahill
 */
public enum Category {
	ALL_CATEGORIES ("All Categories"),
	HEIRLOOM ("Heirloom"),
	KEEPSAKE ("Keepsake"),
	MISC ("Miscellaneous");
	
	String name;
	
	private Category(String name) {
		this.name = name;
	}
	
	@Override
	public String toString() {
		return name;
	}
	
	/**
	 * 
	 * @return A list of the categories that can be posted
	 */
	public static List<Category> getPostCategories() {
		return Arrays.asList(HEIRLOOM, KEEPSAKE, MISC);
	}
	
	/**
	 * 
	 * @return A list of the categories that can be searched
	 */
	public static List<Category> getSearchCategories() {
		return Arrays.asList(ALL_CATEGORIES, HEIRLOOM, KEEPSAKE, MISC);
	}
	
	public static Category getCategory(String category) {
		if (category.equals("Heirloom")) 
			return HEIRLOOM;
		else if (category.equals("Keepsake"))
			return KEEPSAKE;
		else if (category.equals("All Categories"))
			return ALL_CATEGORIES;
		else
			return MISC;
	}
	
	
	/**
	 * 
	 * @return a noun that describes the category
	 */
	public String getNoun() {
		if (name.equals("Miscellaneous"))
			return "Misc Item";
		return name;
	}
}

